package com.community.web.master.controller;


import com.community.common.result.Result;
import com.community.model.entity.Notice;
import com.community.web.master.domain.dto.NoticeDto;
import com.community.web.master.domain.dto.PageNoticeDto;
import com.community.web.master.domain.vo.PageResult;
import com.community.web.master.service.INoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 李晶
 * @since 2024-07-02
 */
@RestController
@RequestMapping("/master/notice")
@Api(tags = "通知公告接口")
@Slf4j
public class NoticeController {
    @Autowired
    private INoticeService iNoticeService;
    @GetMapping("/pageQuery")
    @ApiOperation("通知分页查询")
    public Result<PageResult> pageQuery(PageNoticeDto pageNoticeDto){
        log.info("通知分页查询"+pageNoticeDto);
        PageResult result= iNoticeService.pageQuery(pageNoticeDto);
        return Result.success(result);
    }

    @ApiOperation("公告发布")
    @PostMapping("/add")
    public Result add(@RequestBody NoticeDto noticeDto){
        log.info("发布公告"+noticeDto);
        iNoticeService.add(noticeDto);
        return Result.success();
    }

    @ApiOperation("修改公告状态")
    @PutMapping("/{id}")
    public Result update(@PathVariable Integer id){
        log.info("修改公告状态"+id);
        iNoticeService.updateStatus(id);
        return Result.success();
    }

}
